package com.evil.application.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.evil.application.mapper.FormControlOptionMapper;
import com.evil.application.pojo.bo.application.form.control.option.FormControlOptionBO;
import com.evil.application.pojo.dto.form.control.option.FormOptionRespDTO;
import com.evil.application.pojo.dto.form.control.save.CopyControlDTO;
import com.evil.application.pojo.dto.form.control.save.SaveControlRespDTO;
import com.evil.application.pojo.entity.FormControlOption;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 表单控件下拉选项表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface FormControlOptionService extends IService<FormControlOption> {

    @Override
    FormControlOptionMapper getBaseMapper();

    /**
     * 获取选项
     *
     * @param id id
     * @return FormOptionRespDTO
     */
    FormOptionRespDTO findBaseById(Long id);

    /**
     * 获取选项列表
     *
     * @param ids           ids
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    List<FormOptionRespDTO> findBaseByIds(Collection<Long> ids, boolean filterDeleted);

    /**
     * 获取选项列表
     *
     * @param ids           ids
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    Map<Long, FormOptionRespDTO> findBaseMapByIds(Collection<Long> ids, boolean filterDeleted);

    /**
     * 获取控件选项列表
     *
     * @param controlId     controlId
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    List<FormOptionRespDTO> findBaseByControlId(Long controlId, boolean filterDeleted);

    /**
     * 获取控件选项列表
     *
     * @param controlIds    controlIds
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    List<FormOptionRespDTO> findBaseByControlIds(Collection<Long> controlIds, boolean filterDeleted);

    /**
     * 获取控件选项列表
     *
     * @param controlIds    controlIds
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    Map<Long, List<FormOptionRespDTO>> findBasesByControlIds(Collection<Long> controlIds, boolean filterDeleted);

    /**
     * 获取控件选项列表
     *
     * @param controlIds    controlIds
     * @param filterDeleted filterDeleted
     * @return FormOptionRespDTO 列表
     */
    Map<Long, Map<Long, FormOptionRespDTO>> findBaseMapByControlIds(Collection<Long> controlIds, boolean filterDeleted);

    /**
     * 递归保存控件选项
     *
     * @param controlId          controlId
     * @param parentOptionId     parentOptionId
     * @param optionMap          optionMap
     * @param options            options
     * @param saveControlRespDTO saveControlRespDTO
     */
    void recursionSaveOptions(Long controlId, Long parentOptionId, Map<Long, FormControlOption> optionMap, List<FormOptionRespDTO> options, SaveControlRespDTO saveControlRespDTO);

    /**
     * 递归复制控件选项
     *
     * @param controlId             controlId
     * @param parentOptionId        父级选项
     * @param sourceOptions         当前层级选项
     * @param targetSourceOptionMap 目标源选项
     * @param copyControlDTO        复制参数
     * @param updateSource          是否更新源信息
     */
    void recursionCopyOptions(Long controlId,
                              Long parentOptionId,
                              List<FormControlOptionBO> sourceOptions,
                              Map<Long, FormControlOption> targetSourceOptionMap,
                              CopyControlDTO copyControlDTO,
                              boolean updateSource);
}
